package com.situ.junit;

import java.util.Date;

import org.junit.Test;

import com.situ.domain.Car;
import com.situ.domain.Record;
import com.situ.domain.SpotEnum;
import com.situ.service.RecordArrayList;

public class RecordListTest {
	RecordArrayList recordList = new RecordArrayList();

	@Test
	public void listRecordsTest() {
		for (Record record : recordList.listRecords()) {
			System.out.println(record);
		}
		for(SpotEnum spot : SpotEnum.values()) {
		    System.out.println(spot + ":" + spot.getState());
		}
	}
	
//	@Test
//	public void findCar
	
	@Test
	public void insertAndfind() throws Exception {
		for (Record record : recordList.listRecords()) {
			System.out.println(record);
		}
		System.out.println("*****************");
		recordList.insertRecord(new Record(new Car("鲁C-1LO568", 2.59), SpotEnum.THIRD, new Date()));
		for (Record record : recordList.listRecords()) {
			System.out.println(record);
		}
		Thread.sleep(3000);
		if(0 == recordList.outCar("鲁C-1LO568", 3)) {
		    System.out.println("取车成功");
		}
//		recordTemp.setEndTime(new Date());
//		BigDecimal temp = new BigDecimal((recordTemp.getEndTime().getTime() - recordTemp.getStartTime().getTime()) / 1000 * 2);
//		recordTemp.setCost(temp);
		System.out.println("----------------");
		for (Record record : recordList.listRecords()) {
			System.out.println(record);
		}
		System.out.println(recordList.listRecords().size());
	}
}
